<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>巷陌后台管理系统 - 登录</title>
    <link rel="stylesheet" href="../static/css/all.min.css">
    <script src="../static/js/jquery.js"></script>
    <script src="../static/js/jquery.cookie.js"></script>
    <style>
        :root {
            --primary-color: #3a6ea5;
            --secondary-color: #6b8ead;
            --accent-color: #ff6b6b;
            --dark-color: #2c3e50;
            --light-color: #f5f7fa;
            --success-color: #2ecc71;
            --warning-color: #f39c12;
            --danger-color: #e74c3c;
        }

        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
        }

        body {
            background-color: #f0f2f5;
            color: #333;
            height: 100vh;
            display: flex;
            justify-content: center;
            align-items: center;
            background-image: linear-gradient(135deg, rgba(58, 110, 165, 0.05) 0%, rgba(107, 142, 173, 0.1) 100%);
        }

        .login-container {
            display: flex;
            width: 900px;
            height: 500px;
            background: white;
            border-radius: 15px;
            overflow: hidden;
            box-shadow: 0 15px 30px rgba(0, 0, 0, 0.1);
        }

        .login-left {
            flex: 1;
            background: linear-gradient(135deg, var(--primary-color), var(--dark-color));
            color: white;
            display: flex;
            flex-direction: column;
            justify-content: center;
            align-items: center;
            padding: 40px;
            position: relative;
            overflow: hidden;
        }

        .login-left::before {
            content: '';
            position: absolute;
            top: -50px;
            left: -50px;
            width: 200px;
            height: 200px;
            border-radius: 50%;
            background: rgba(255, 255, 255, 0.1);
        }

        .login-left::after {
            content: '';
            position: absolute;
            bottom: -80px;
            right: -80px;
            width: 250px;
            height: 250px;
            border-radius: 50%;
            background: rgba(255, 255, 255, 0.1);
        }

        .logo {
            text-align: center;
            margin-bottom: 30px;
            z-index: 1;
        }

        .logo i {
            font-size: 3.5rem;
            margin-bottom: 15px;
            color: #ffd166;
        }

        .logo h1 {
            font-size: 2rem;
            font-weight: 600;
            margin-bottom: 10px;
        }

        .logo p {
            font-size: 1rem;
            opacity: 0.9;
        }

        .features {
            margin-top: 30px;
            z-index: 1;
        }

        .feature {
            display: flex;
            align-items: center;
            margin-bottom: 20px;
        }

        .feature i {
            font-size: 1.2rem;
            margin-right: 15px;
            color: #ffd166;
            width: 24px;
            text-align: center;
        }

        .feature span {
            font-size: 0.95rem;
        }

        .login-right {
            flex: 1;
            display: flex;
            flex-direction: column;
            justify-content: center;
            align-items: center;
            padding: 40px;
        }

        .login-form {
            width: 100%;
            max-width: 350px;
        }

        .login-header {
            text-align: center;
            margin-bottom: 30px;
        }

        .login-header h2 {
            font-size: 1.8rem;
            color: var(--dark-color);
            margin-bottom: 10px;
        }

        .login-header p {
            color: #777;
            font-size: 0.95rem;
        }

        .form-group {
            margin-bottom: 20px;
            position: relative;
        }

        .form-group i {
            position: absolute;
            left: 15px;
            top: 50%;
            transform: translateY(-50%);
            color: #aaa;
        }

        .form-control {
            width: 100%;
            padding: 12px 15px 12px 45px;
            border: 1px solid #ddd;
            border-radius: 8px;
            font-size: 1rem;
            transition: all 0.3s ease;
        }

        .form-control:focus {
            border-color: var(--primary-color);
            box-shadow: 0 0 0 3px rgba(58, 110, 165, 0.2);
            outline: none;
        }

        .remember-forgot {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 20px;
            font-size: 0.9rem;
        }

        .remember {
            display: flex;
            align-items: center;
        }

        .remember input {
            margin-right: 8px;
        }

        .forgot-password {
            color: var(--primary-color);
            text-decoration: none;
            transition: color 0.3s ease;
        }

        .forgot-password:hover {
            color: var(--dark-color);
            text-decoration: underline;
        }

        .btn-login {
            width: 100%;
            padding: 12px;
            background: linear-gradient(135deg, var(--primary-color), var(--dark-color));
            color: white;
            border: none;
            border-radius: 8px;
            font-size: 1rem;
            font-weight: 500;
            cursor: pointer;
            transition: all 0.3s ease;
        }

        .btn-login:hover {
            transform: translateY(-2px);
            box-shadow: 0 5px 15px rgba(58, 110, 165, 0.3);
        }

        .btn-login:active {
            transform: translateY(0);
        }

        .login-footer {
            margin-top: 20px;
            text-align: center;
            font-size: 0.9rem;
            color: #777;
        }

        /* 响应式设计 */
        @media (max-width: 992px) {
            .login-container {
                width: 90%;
                height: auto;
                flex-direction: column;
            }

            .login-left {
                padding: 30px;
                border-radius: 15px 15px 0 0;
            }

            .login-right {
                padding: 30px;
                border-radius: 0 0 15px 15px;
            }
        }

        @media (max-width: 576px) {
            .login-container {
                width: 95%;
            }

            .login-left, .login-right {
                padding: 20px;
            }

            .logo h1 {
                font-size: 1.7rem;
            }

            .login-header h2 {
                font-size: 1.5rem;
            }
        }

        /* 错误提示 */
        .error-message {
            color: var(--danger-color);
            font-size: 0.85rem;
            margin-top: 5px;
            display: none;
        }

        .form-group.error .form-control {
            border-color: var(--danger-color);
        }

        .form-group.error .error-message {
            display: block;
        }

        /* 加载动画 */
        .btn-loading {
            position: relative;
            color: transparent !important;
        }

        .btn-loading::after {
            content: '';
            position: absolute;
            width: 20px;
            height: 20px;
            top: 50%;
            left: 50%;
            margin: -10px 0 0 -10px;
            border: 2px solid rgba(255, 255, 255, 0.3);
            border-radius: 50%;
            border-top-color: white;
            animation: spin 0.8s ease infinite;
        }

        @keyframes spin {
            to {
                transform: rotate(360deg);
            }
        }
    </style>
</head>
<body>
<div class="login-container">
    <div class="login-left">
        <div class="logo">
            <i class="fas fa-map-marked-alt"></i>
            <h1>巷陌后台管理系统</h1>
            <p>探索城市中的每一处精彩</p>
        </div>
        <div class="features">
            <div class="feature">
                <i class="fas fa-shield-alt"></i>
                <span>安全可靠的管理系统</span>
            </div>
            <div class="feature">
                <i class="fas fa-chart-line"></i>
                <span>全面的数据统计分析</span>
            </div>
            <div class="feature">
                <i class="fas fa-bolt"></i>
                <span>高效便捷的操作体验</span>
            </div>
        </div>
    </div>
    <div class="login-right">
        <div class="login-form">
            <div class="login-header">
                <h2>管理员登录</h2>
                <p>请输入您的账号和密码登录系统</p>
            </div>
            <form id="loginForm">
                <div class="form-group" id="usernameGroup">
                    <i class="fas fa-user"></i>
                    <input type="text" class="form-control" id="username" placeholder="管理员账号" autocomplete="off">
                    <div class="error-message" id="usernameError">请输入有效的管理员账号</div>
                </div>
                <div class="form-group" id="passwordGroup">
                    <i class="fas fa-lock"></i>
                    <input type="password" class="form-control" id="password" placeholder="登录密码">
                    <div class="error-message" id="passwordError">密码不能为空</div>
                </div>
                <button type="submit" class="btn-login" id="loginBtn">登录</button>
            </form>
            <div class="login-footer">
                <p>© 2023 巷陌后台管理系统 | 仅限授权人员访问</p>
            </div>
        </div>
    </div>
</div>

<script>
    document.addEventListener('DOMContentLoaded', function() {
        const loginForm = document.getElementById('loginForm');
        const usernameInput = document.getElementById('username');
        const passwordInput = document.getElementById('password');
        const usernameGroup = document.getElementById('usernameGroup');
        const passwordGroup = document.getElementById('passwordGroup');
        const loginBtn = document.getElementById('loginBtn');

        // 检查是否有保存的用户名
        const savedUsername = localStorage.getItem('adminUsername');
        const rememberMe = localStorage.getItem('rememberMe') === 'true';

        if (savedUsername && rememberMe) {
            usernameInput.value = savedUsername;
            document.getElementById('remember').checked = true;
        }

        // 表单提交事件
        loginForm.addEventListener('submit', function(e) {
            e.preventDefault();

            let isValid = true;

            // 验证用户名
            if (!usernameInput.value.trim()) {
                usernameGroup.classList.add('error');
                isValid = false;
            } else {
                usernameGroup.classList.remove('error');
            }

            // 验证密码
            if (!passwordInput.value) {
                passwordGroup.classList.add('error');
                isValid = false;
            } else {
                passwordGroup.classList.remove('error');
            }            if (isValid) {
                // 模拟登录过程
                loginBtn.classList.add('btn-loading');

                //     写接口
                $.ajax({
                    url:"/admin/login",
                    type:"post",
                    data:{
                        account:usernameInput.value,
                        password:passwordInput.value
                    },
                    success:function (res){
                        console.log(res)
                        if(res.code == 200){
                            $.cookie("adminName",res.data.adminName)
                            location.href="/lanebank"
                        }
                    },error:function (res){
                        alert("登录失败！请检查密码和账户!")
                    }
                })
            }
        });



        // 输入时移除错误状态
        usernameInput.addEventListener('input', function() {
            usernameGroup.classList.remove('error');
        });

        passwordInput.addEventListener('input', function() {
            passwordGroup.classList.remove('error');
        });
    });
</script>
</body>
</html>